//
//  HomeworkViewController.h
//  HondaPro_2
//
//  Created by Eric on 13-7-31.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MainMenuDataModel.h"
#import "HelpClass.h"
#import "webConfig.h"
#import "webService.h"
#import "mm_codeItemForRepairItemViewController.h"

#import "DDPopoverBackgroundView.h"
#import "popContentViewController.h"

@interface HomeworkViewController : UIViewController <UITableViewDataSource,UITableViewDelegate,ContentViewControllerDelegate>
{
    //属性
    NSArray *_arrOriginalDataForServiceType;
    NSMutableArray *_arrDisDataForServiceType;
    NSInteger _nRowServiceTypeSel;
    
    NSArray *_arrOriginalDataForRepairType;
    NSMutableArray *_arrDisDataForRepairType;
    NSInteger _nRowRepairTypeSel;
    
    NSArray *_arrOriginalDataForWorkShop;
    NSMutableArray *_arrDisDataForWorkShop;
    NSInteger _nRowWorkShop;
    
    //弹出框控制器 实例
    mm_codeItemForRepairItemViewController *_vc;
    
    //下拉菜单的属性
    popContentViewController *_contentCon;
    UIPopoverController *_popCon;
    
    //要删除的用户陈述和作业指示行
    NSInteger _nStatementRowDel;
    NSInteger _nIndicationRowDel;
}

@property (strong, nonatomic) IBOutlet UITableView *resultTableViewDis;
@property (strong, nonatomic) IBOutlet UITableView *indicationTableViewDis;
@property (strong, nonatomic) IBOutlet UITextField *statementNumberTxt;
@property (strong, nonatomic) IBOutlet UITextField *statementContentTxt;
@property (strong, nonatomic) IBOutlet UITextField *indicationNumberTxt;
@property (strong, nonatomic) IBOutlet UITextField *indicationContentTxt;
@property (strong, nonatomic) IBOutlet UIButton *symptomBtn;
@property (strong, nonatomic) IBOutlet UIButton *faultCodeBtn;
@property (strong, nonatomic) IBOutlet UIButton *actionCodeBtn;
@property (strong, nonatomic) IBOutlet UIButton *serviceTypeBtn;
@property (strong, nonatomic) IBOutlet UIButton *workShopBtn;
@property (strong, nonatomic) IBOutlet UIButton *repairTypeBtn;

//缓冲所有向服务器请求的数据
-(void)bufferingAllTheWebData;
//创建下拉菜单
-(void)createThePopViewControl:(UIButton *)sender;
//刷新作业指示的方法
-(void)freshenIndication;
//刷新用户陈述的方法
-(void)freshenResults;
//进入界面时的初始化操作
-(void)initTheHomeWorkAtFirst;
//返回用户陈述的个数
-(NSInteger)resultsSum;
//返回作业指示的总个数
-(NSInteger)indicationSum;
//得到最大陈述号的算法
-(NSInteger)resultsMaxNumber;
//得到最大作业指示的算法
-(NSInteger)indicationMaxNumber;
//用户陈述行选中的操作
-(void)resultsRowBeSelected;
//作业指示行选中的操作
-(void)indicationRowBeSelected;
//修改用户陈述信息的操作
-(void)changeTheResultsDataByStatementNumber:(NSString *)statementNumber;
//修改作业指示信息的操作
-(void)changeTheIndicationDataByStatementNumber:(NSString *)statementNumber andIndicationNumber:(NSString *)indicationNumber;
//新增用户陈述
-(void)addTheResultsDataByStatementNumber:(NSString *)statementNumber;
//新增作业指示
-(void)addTheIndicationDataByStatementNumber:(NSString *)statementNumber andIndicationNumber:(NSString *)indicationNumber;

/*按钮回调方法*/
//返回按钮的回调方法
- (IBAction)backBtnPressed:(UIButton *)sender;
//成组录入按钮的回调方法
- (IBAction)jobItemGroupBtnPressed:(UIButton *)sender;
//用户陈述新增按钮按下的操作
- (IBAction)addBeginBtnPressed:(UIButton *)sender;
//作业指示新增按钮按下的操作
- (IBAction)indicationAddBeginBtnPressed:(UIButton *)sender;
//用户陈述确定按钮按下的操作
- (IBAction)OkBtnPressed:(UIButton *)sender;
//作业指示确定按钮按下的操作
- (IBAction)indicationOkBtnPressed:(UIButton *)sender;
//症状代码、故障代码、处理代码按钮的操作
- (IBAction)codeBtnPressed:(UIButton *)sender;
//服务类型按钮回调方法
- (IBAction)serviceTypeBtnPressed:(UIButton *)sender;
//车间区分按钮回调方法
- (IBAction)workShopBtnPressed:(UIButton *)sender;
//修理类型按钮的回调方法
- (IBAction)repairTypeBtnPressed:(UIButton *)sender;
/*end of 按钮回调方法*/

/*注册消息*/
-(void)addObserverAtFirst;
/*end of 注册消息*/

/*移除消息*/
-(void)removeObserverAtLast;
/*end of 移除消息*/

/*webService请求数据*/
//请求网络数据
-(void)getWebServiceDataByString:(NSString *)strMsg andArrObject:(NSMutableArray *)arrWebData;
/*end of webService请求数据*/

/*webService回调方法*/
//请求服务类型的回调方法
-(void)getServiceTypeList:(NSNotification *)notification;
//请求车间区分的回调方法
-(void)getWorkShopList:(NSNotification *)notification;
//请求修理类型的回调方法
-(void)getRepairTypeList:(NSNotification *)notification;
//请求是否可以删除用户陈述、作业指示
-(void)getCanDeleteData:(NSNotification *)notification;
/*end of webService回调方法*/

//判断服务类型和修理类型是否可以选择
-(BOOL)serviceOrRepairTypeCanSelByServiceTypeId:(NSString *)serviceTypeId andRepairTypeId:(NSString *)repairTypeId;
//根据ID取name
-(NSString *)getNameByServiceId:(NSString *)serviceId;
-(NSString *)getNameByRepairId:(NSString *)RepairId;
//判断服务类型是否是属于“保修”
-(BOOL)serviceTypeIsWarranty:(NSString *)serviceTypeName;
//判断修理类型是否是属于“首保”
-(BOOL)repairTypeIsFirstWarranty:(NSString *)repairTypeName;
//根据列表的编号取服务类型的ID
-(NSString *)getServiceTypeIdByRowSel:(NSInteger)rowSel;
//根据列表的编号取修理类型的ID
-(NSString *)getRepairTypeIdByRowSel:(NSInteger)rowSel;

//判断用户陈述或者作业指示中是否有保修的项目
-(BOOL)hasWarrantyItemInStatementByStatementNumber:(NSInteger)statementNumber andIndication:(NSInteger)indicationNumber;
//根据用户陈述和作业指示序号删除用户陈述和作业指示
-(void)delStatementAndIndicationByStatementNumber:(NSInteger)statementNumber andIndicationNumber:(NSInteger)indicationNumber;
//根据用户陈述和作业指示序号刷新用户陈述和作业指示表单
-(void)freshenStatementAndIndicationTableByStatementNumber:(NSInteger)statementNumber andIndicationNumber:(NSInteger)indicationNumber;

//修理类型和车间区分之间的联动关系
-(void)repairTypeControlWorkShopTypeByRepairTypeRowSel:(NSInteger)repairTypeRowSel;

@end
